/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.GuestbookDAO;
import com.sesame.domain.Guestbook;

/**
 * @author shubeta
 * 
 */
public class GuestbookDAOImpl extends SqlMapClientDaoSupport implements
        GuestbookDAO {

    public void addGuestbook(Guestbook guestbook) {
        getSqlMapClientTemplate().insert("addGuestbook", guestbook);
    }

    public void deleteGuestbookById(Integer id) {
        getSqlMapClientTemplate().delete("deleteGuestbookById", id);
    }

    @SuppressWarnings("unchecked")
    public List<Guestbook> getAllGuestbook(Integer hostUserId) {
        return (List<Guestbook>) getSqlMapClientTemplate().queryForList(
                "getAllGuestbook", hostUserId);
    }

    public List<Guestbook> getTopGuestbook(Integer hostUserId) {
        return (List<Guestbook>) getSqlMapClientTemplate().queryForList(
                "getTopGuestbook", hostUserId);
    }

    public Guestbook getGuestbookByNickName(String nickName) {
        return (Guestbook) getSqlMapClientTemplate().queryForObject(
                "getGuestbookByNickName", nickName);
    }

    public void updateGuestbook(Guestbook guestbook) {
        getSqlMapClientTemplate().update("updateGuestbook", guestbook);
    }
}